#ifndef SHOPDIALOG_H
#define SHOPDIALOG_H

#include <QGraphicsObject>
#include <QEventLoop>
#include "foregroundscene.h"
#include "dice.h"
#include "gameanimation.h"


class ShopBackground : public QGraphicsObject
{
public:
    ShopBackground(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

};

class ShopTextInfo : public QGraphicsObject
{
public:
    ShopTextInfo(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    static const int SHOP_TEXT_WIDTH = 400;
};


class ShopOwner : public QGraphicsObject
{
public:
    ShopOwner(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);

    static const int SHOP_OWNER_WIDTH = 80;
    static const int SHOP_OWNER_HEIGHT = 80;
};

class ShopOwnerBig : public QGraphicsObject
{
public:
    ShopOwnerBig(QGraphicsObject* parent, const QPixmap &pix);
    QRectF boundingRect() const;
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
protected:
    QPixmap _pix;
};

class ShopDialog : public QGraphicsObject
{
    Q_OBJECT
public:
    ShopDialog(QGraphicsObject* parent = 0);
    QRectF boundingRect() const;   
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
    void enter();

    static const int SHOP_WIDTH = 500;
    static const int SHOP_HEIGHT = 500;
protected:
    ShopBackground* back;
    ShopOwner* owner;
    ShopOwnerBig* ownerBig;
    ShopTextInfo* text;
    ForegroundScene* foreScene;

    GameSeqAnimation* enterAnim;

    void prepare();
    void createAnimation();
    virtual void shopping() = 0;
signals:
    void readyToCleanUp();
public slots:
    void waitForClickEnter();
    void waitForClickExit();
    void shop();
    void leave();
    void finished();
};

class TeashopDialog : public ShopDialog
{
public:
    TeashopDialog(QGraphicsObject* parent, const QPixmap &pix);
protected:
    void shopping();
};

class SorcererDialog : public ShopDialog
{
public:
    SorcererDialog(QGraphicsObject* parent, const QPixmap &pix);
protected:
    void shopping();
};

class AltarDialog : public ShopDialog
{
public:
    AltarDialog(QGraphicsObject* parent, const QPixmap &pix);
protected:
    void shopping();
};

class PavilionDialog : public ShopDialog
{
public:
    PavilionDialog(QGraphicsObject* parent, const QPixmap &pix);
protected:
    void shopping();
};
#endif // SHOPDIALOG_H
